import { BaseEntity } from '../../base/entity/base';
import { Column, Entity, Index } from 'typeorm';

/**
 * 支付模块-余额变动记录表
 */
@Entity('pay_balance_log')
export class PayBalanceLogEntity extends BaseEntity {
  @Index()
  @Column({ comment: '用户ID' })
  userId: number;

  @Index()
  @Column({ comment: '订单ID', nullable: true })
  orderId: number;

  @Column({ comment: '订单号', length: 32, nullable: true })
  orderNo: string;

  @Column({
    comment: '变动类型',
    dict: ['充值', '消费', '退款', '冻结', '解冻', '系统调整', '提现'],
    default: 0,
  })
  changeType: number;

  @Column({ comment: '变动金额', type: 'decimal', precision: 10, scale: 2 })
  changeAmount: number;

  @Column({ comment: '变动前余额', type: 'decimal', precision: 10, scale: 2 })
  beforeBalance: number;

  @Column({ comment: '变动后余额', type: 'decimal', precision: 10, scale: 2 })
  afterBalance: number;

  @Column({
    comment: '余额类型',
    dict: ['可用余额', '冻结余额'],
    default: 0,
  })
  balanceType: number;

  @Column({
    comment: '业务类型',
    dict: [
      '充值余额',
      '购买流量',
      '电话通知充值',
      '物联网卡充值',
      '短信通知充值',
      '系统调整',
      '退款',
    ],
    default: 0,
  })
  businessType: number;

  @Column({ comment: '业务ID', nullable: true })
  businessId: number;

  @Column({ comment: '变动描述', length: 500 })
  description: string;

  @Column({ comment: '操作人ID', nullable: true })
  operatorId: number;

  @Column({
    comment: '操作人类型',
    dict: ['系统', '用户', '管理员'],
    default: 0,
  })
  operatorType: number;

  @Column({ comment: '备注', type: 'text', nullable: true })
  remark: string;

  @Column({ comment: '扩展信息', type: 'json', nullable: true })
  extInfo: any;
}
